import React, {memo, useState} from 'react';
import {Button, Input, Modal} from "antd";
import styles from "./index.less";

const UserFeedBack = ({userId, openModel, handelOk, handelCancel,submitFeedback}) => {
  //所选意见类型
  const [feedbackType, setFeedbackType] = useState(null);
  const [feedbackTypeShow, setFeedbackTypeShow] = useState(false);
  //意见的所有类型
  const [feedbackList, setFeedbackList] = useState([]);
  //意见文本
  const [feedbackText, setFeedbackText] = useState("");
  const [feedbackTextShow, setFeedbackTextShow] = useState(false);
  //所选意见反馈提示
  const [feedbackTip, setFeedbackTip] = useState("");
  // useEffect(async () => {
  //   getOpinionList({ userId: userId,type:"0" }).then(res => {
  //     if (res.code === 200) {
  //       if (Array.isArray(res.data) && res.data.length > 0) {
  //         setFeedbackList(res.data);
  //       }
  //     } else {
  //       message.error(res.message);
  //     }
  //   });
  // }, [])
  const handleCancel = () => {
    // setOpenModel1(false)
    setFeedbackTypeShow(false)
    setFeedbackTextShow(false)
    setPhoneNumberError(false)
    setPhoneNumber(null)
    setFeedbackType(null)
    setFeedbackText("")
    handelCancel()
  };

  const handleOk= async ()=> {
    submitFeedback(feedbackText);
    handelCancel()
    setFeedbackText('')
  }

  // 手机号
  const [phoneNumber, setPhoneNumber] = useState(null)
  const [phoneNumberError, setPhoneNumberError] = useState(false)

  // 弹窗
  return (
    <div className={styles.feedbackContainer}>
      {/*<img className={styles.img} src={u412} alt="" onClick={event => setOpenModel1(true)} />*/}
      <Modal
        open={openModel}
        title="智能指标助手反馈"
        centered
        multiple
        maxCount={4}
        mask={false}
        onCancel={handleCancel}
        width={'50%'}
        footer={[
          <div style={{width: '100%', textAlign: 'center'}} key="model-Feed">
            <Button className={styles.feedbackBtnCancel} onClick={handleCancel}>
              取消
            </Button>
            <Button className={styles.feedbackBtn} onClick={handleOk}>
              提交
            </Button>
          </div>,
        ]}
      >
        <div className={styles.feedback}>
          <div className={styles.feedbackTitle}>
            你的反馈将帮助智能助手优化进步
          </div>
          <div style={{position: "relative"}}>
            <Input.TextArea
              className={styles.feedbackOpinionInput}
              value={feedbackText}
              onChange={event => {
                setFeedbackText(event.target.value);
                setFeedbackTextShow(event.target.value ? false : true)
              }}
              rows={6}
              placeholder={feedbackTip?feedbackTip:'留下您的反馈'}
            />
            {!feedbackText && <div className={styles.contentItemMust} style={{top: '3px', left: `${feedbackTip?12+14*feedbackTip.length:96}px`}}>*</div>}
          </div>
          <div className={styles.errorMessage}>{feedbackTextShow && '请留下您的反馈'}</div>
        </div>
      </Modal>
    </div>
  )
}
export default memo(UserFeedBack)
